package org.googlecode.openapi_java;

import org.json.JSONException;
import org.json.JSONObject;

public class Photo {
	private long pid;
	private long aid;
	private long owner_id;
	private String src;
	private String src_small;
	private String src_big;
	private long created;

	private String  src_xbig;
	private String  src_xxbig;

	
	
	
    public long getPid() {
		return pid;
	}

	public long getAid() {
		return aid;
	}
	
	public long getOwner_id() {
		return owner_id;
	}

	public String getSrc() {
		return src;
	}

	public String getSrc_small() {
		return src_small;
	}

	public String getSrc_big() {
		return src_big;
	}

	public long getCreated() {
		return created;
	}

	public String getSrc_xbig() {
		return src_xbig;
	}

	public String getSrc_xxbig() {
		return src_xxbig;
	}
	
	public static Photo fromJSON(JSONObject jsonObject) throws JSONException {
        Photo photo = new Photo();
        System.out.println("Photo " + jsonObject);
        /*if (jsonObject.has("pid"))*/ photo.pid = jsonObject.getLong("pid");
        /*if (jsonObject.has("aid"))*/ photo.aid = jsonObject.getLong("aid");
        /*if (jsonObject.has("owner_id"))*/ photo.owner_id = jsonObject.getLong("owner_id");
        /*if (jsonObject.has("src"))*/ photo.src = jsonObject.getString("src");
        /*if (jsonObject.has("src_small"))*/ photo.src_small = jsonObject.getString("src_small");
        /*if (jsonObject.has("src_big"))*/ photo.src_big = jsonObject.getString("src_big");
        /*if (jsonObject.has("created"))*/ photo.created = jsonObject.getLong("created");
        if (jsonObject.has("src_xbig")) photo.src_xbig = jsonObject.getString("src_xbig");
        if (jsonObject.has("src_xxbig")) photo.src_xxbig = jsonObject.getString("src_xxbig");
        return photo;
    }

    @Override
    public String toString() {
        return "Photo{" +
                "pid=" + pid +
                ", aid=" + aid +
                ", owner_id=" + owner_id +
                ", src='" + src + '\'' +
                ", src_small='" + src_small + '\'' +
                ", src_big='" + src_big + '\'' +
                ", created=" + created +
                ", src_xbig='" + src_xbig + '\'' +
                ", src_xxbig='" + src_xxbig + '\'' +
                '}';
    }
}
